import { getStore } from '@/util/store'

const dic = {
  riskLevel: [
    { label: 'Y', value: '0' },
    { label: 'R', value: '1' },
    { label: 'A', value: '2' },
    { label: 'G', value: '3' }
  ],
  possibility: [
    { label: '极低的', value: '0' },
    { label: '不太可能的', value: '1' },
    { label: '有小概率可能', value: '2' },
    { label: '有大概率可能', value: '3' },
    { label: '几乎肯定发生', value: '4' }
  ],
  riskResult: [
    { label: '轻微', value: '0' },
    { label: '低的', value: '1' },
    { label: '中等', value: '2' },
    { label: '高的', value: '3' },
    { label: '严重的', value: '4' }
  ]
}
export const option = function () {
  return {
    refreshBtn: true,
    columnBtn: true,
    border: true,
    stripe: true,
    index: true,
    editBtn: true,
    delBtn: true,
    align: 'center',
    addBtn: !['view'].includes(this.type),
    addBtnText: '添加措施',
    menu: !['view'].includes(this.type),
    labelWidth: 160,
    indexLabel: '序号',
    column: [
      {
        label: '风险措施',
        prop: 'measuresName',
        type: 'textarea',
        minRows: 4,
        maxRows: 5,
        maxlength: 500,
        span: 24,
        rules: [
          {
            required: true,
            message: '请输入风险措施',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '处置办法',
        prop: 'handleMethod',
        type: 'textarea',
        minRows: 4,
        maxRows: 5,
        maxlength: 500,
        span: 24
      },
      {
        label: '措施后风险可能性',
        prop: 'measuresPossibility',
        type: 'select',
        dicData: dic.possibility,
        props: {
          label: 'label',
          value: 'value'
        },
        rules: [
          {
            required: true,
            message: '请选择措施后风险可能性',
            trigger: 'change'
          }
        ]
      },
      {
        label: '措施后风险结果',
        prop: 'measuresResult',
        type: 'select',
        dicData: dic.riskResult,
        props: {
          label: 'label',
          value: 'value'
        },
        rules: [
          {
            required: true,
            message: '请选择措施后风险结果',
            trigger: 'change'
          }
        ]
      },
      {
        label: '措施后风险等级',
        prop: 'measuresLevel',
        formslot: true,
        slot: true
      },
      {
        label: '措施创建人',
        prop: 'measuresPerson',
        value: getStore({ name: 'userInfo' }).user_name,
        addDisplay: false,
        editDisplay: false,
        viewDisplay: false
      },
      {
        label: '创建日期',
        prop: 'measuresDate',
        type: 'date',
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        value: new Date(),
        addDisplay: false,
        editDisplay: false,
        viewDisplay: false
      }
    ]
  }
}
